package com.ml.ws.service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.util.Assert;

import com.ml.enums.RequestType;

public class RequestFactory {
    private static Map<RequestType, RequestService> services = new ConcurrentHashMap<RequestType, RequestService>();

    public static RequestService getByRequestType(RequestType requestType) {
        return services.get(requestType);
    }

    public static void register(RequestType requestType, RequestService requestService) {
        Assert.notNull(requestType, "request Type can't be null");
        services.put(requestType, requestService);
    }
}